<!--
  ~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  ~
  ~ This file is part of retabel.
  ~
  ~ Copyright (c) 2011 by individual contributors as indicated by the
  ~ @author tags. See the copyright.txt file in the distribution
  ~ for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:c="http://java.sun.com/jstl/core"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:t="http://myfaces.apache.org/tomahawk">

<body>

<ui:composition template="/templates/template.xhtml">

    <ui:define name="title">
        <h:outputText value="#{_msg['retabel.text.title']}"/>
    </ui:define>

    <ui:define name="navigation">
        <ui:include src="navigation.xhtml"/>
    </ui:define>

    <ui:define name="body">

        <h:outputStylesheet>

            th {
                text-align: left;
                font-weight: bold;
            }

            td.iconColumn {
            }

            td.nameColumn {
                text-align: left;
                min-width: 100px;
            }

            td.typeColumn {
                text-align: left;
                min-width: 100px;
            }

            td.valueColumn {
                text-align: left;
                min-width: 250px;
            }

            td.valueColumn input {
                width: 100%;
            }

            .error {
                color: red;
            }

            .deleteIcon {
                width: 16px;
                height: 16px;
            }

        </h:outputStylesheet>

        <rich:panel>

            <f:facet name="header">
                <h:panelGroup>
                    <h:outputText value="#{_msg['retabel.text.configsets']}" />
                </h:panelGroup>
            </f:facet>

            <h:form id="form">
                <h:panelGrid>
                    <t:dataTable value="#{configSetListBean.tableModel}"
                                 var="_configSet"
                                 binding="#{configSetListBean.uiData}"
                                 columnClasses="nameColumn"
                                 rows="10"
                                 id="configSetTable">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{_msg['retabel.text.configset.name']}"/>
                            </f:facet>
                            <h:commandLink action="#{configSetListBean.edit}">
                                <f:param name="name" value="#{_configSet.name}" />

                                <h:outputText value="#{_configSet.name}"/>
                            </h:commandLink>
                        </h:column>
                        <f:facet name="footer">
                            <rich:dataScroller id="paginator" maxPages="10" status="ajaxStatus" ajaxSingle="false">
                            </rich:dataScroller>
                        </f:facet>
                    </t:dataTable>

                </h:panelGrid>

                <h:panelGroup rendered="#{not empty configSetListBean.name}">

                    <hr />

                    <t:dataTable value="#{configSetListBean.attributeDataModel}"
                                 var="_configAttribute"
                                 binding="#{configSetListBean.uiAttributeData}"
                                 columnClasses="nameColumn, typeColumn, valueColumn">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{_msg['retabel.text.configset.name']}"/>
                            </f:facet>
                            <h:outputText value="#{_configAttribute.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{_msg['retabel.text.configset.type']}"/>
                            </f:facet>
                            <h:outputText value="#{_configAttribute.type}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="#{_msg['retabel.text.configset.value']}"/>
                            </f:facet>
                            <h:panelGroup>
                                <h:inputText id="attributeValue" value="#{_configAttribute.value}" required="true">
                                </h:inputText>
                                <h:message for="attributeValue" errorClass="error"/>
                            </h:panelGroup>
                        </h:column>
                        <h:column>
                            <h:commandButton value="#{_msg['retabel.button.submit']}" action="#{configSetListBean.save}">
                                <f:param name="name" value="#{configSetListBean.name}" />
                            </h:commandButton>
                        </h:column>
                    </t:dataTable>

                </h:panelGroup>

            </h:form>

            <h:dataTable var="_logLine" value="#{configSetListBean.attributeLogLines}">
                <h:column>
                    <pre><h:outputText value="#{_logLine.message}"/></pre>
                </h:column>
                <h:column>
                    <pre><h:outputText value="#{_logLine.throwable}"/></pre>
                </h:column>
            </h:dataTable>

        </rich:panel>

    </ui:define>

</ui:composition>

</body>
</html>
